import config from "@/config"
import http from "@/utils/request"
import { MenuSaveDto, MenuDelDto } from './types'
import { ApiResult } from '@/api/common/ApiResultType'
import { SysMenuInfoBo, MenuButtonVo, MenuInfoVo } from './types'
export default {
	/**
	 * 获取当前所有菜单
	 */
	getmenus: {
		url: `${config.API_URL}/sysmenu/getmenus`,
		name: "获取当前所有菜单",
		post: async function () {
			var res: ApiResult<SysMenuInfoBo[]> = await http.post(this.url);
			return res;
		}
	},
	/**
	 * 获取当前所有菜单与按钮的映射关系
	 */
	getmenufunctions: {
		url: `${config.API_URL}/sysmenu/getmenufunctions`,
		name: "获取当前所有菜单与按钮的映射关系",
		post: async function () {
			var res: ApiResult<MenuButtonVo> = await http.post(this.url);
			return res;
		}
	},
	/**
	 * 菜单保存
	 */
	menusave: {
		url: `${config.API_URL}/sysmenu/menusave`,
		name: "菜单保存",
		post: async function (data: MenuSaveDto) {
			var res: ApiResult = await http.post(this.url, data);
			return res;
		}
	},
	/**
	 * 删除菜单
	 */
	menudel: {
		url: `${config.API_URL}/sysmenu/menudel`,
		name: "删除角色信息",
		post: async function (data: MenuDelDto) {
			var res: ApiResult = await http.post(this.url, data);
			return res;
		}
	},
	/**
	 * 获取所有菜单信息 无children
	 */
	getmenuiconlist: {
		url: `${config.API_URL}/sysmenu/getmenuiconlist`,
		name: "删除角色信息",
		post: async function () {
			var res: ApiResult<MenuInfoVo[]> = await http.post(this.url);
			return res;
		}
	},
	/**
	 * 将首页的按钮都插入到redis中
	 */
	pushhomemenulist: {
		url: `${config.API_URL}/sysmenu/pushhomemenulist`,
		name: "将首页的按钮都插入到redis中",
		post: async function (data: MenuInfoVo[]) {
			var res: ApiResult = await http.post(this.url, data);
			return res;
		}
	},
	/**
	 * 获取首页的缓存的菜单信息
	 */
	gethomemenulist: {
		url: `${config.API_URL}/sysmenu/gethomemenulist`,
		name: "获取首页的缓存的菜单信息",
		post: async function () {
			var res: ApiResult<MenuInfoVo[]> = await http.post(this.url);
			return res;
		}
	}
}
